package com.ljc;

import lombok.extern.slf4j.Slf4j;

import java.util.Arrays;

/**
 * Hello world!
 *
 */
@Slf4j
public class App 
{

    public void a() {
        b();
    }

    public void b() {
        c();
    }

    public void c() {
        d();
    }

    public void d() {
        for (StackTraceElement element : Thread.currentThread().getStackTrace()) {
            log.info("className: {}, methodName: {}, fileName: {}, lineNumber: {}", element.getClassName(), element.getMethodName(), element.getFileName(), element.getLineNumber());
        }
    }

    public static void main( String[] args )
    {
        log.info( "start main" );

        Runnable runnable = new Runnable() {

            private int count = 10;

            @Override
            synchronized public void run() {
                count--;
                log.info("{}: {}", Thread.currentThread().getName(), count);
            }
        };

        Thread t1 = new Thread(runnable, "T-1");
        Thread t2 = new Thread(runnable, "T-2");
        Thread t3 = new Thread(runnable, "T-3");
        Thread t4 = new Thread(runnable, "T-4");
        Thread t5 = new Thread(runnable, "T-5");
        Thread t6 = new Thread(runnable, "T-6");

        t1.start();
        t2.start();
        t3.start();
        t4.start();
        t5.start();
        t6.start();
//        new App().a();
    }
}
